package com.easyOrder.core.utils;

import org.apache.commons.lang3.StringUtils;

public final class NameUtil {
	public static String toCamel(String name) {
		return Character.toLowerCase(name.charAt(0))
				+ StringUtils.substring(name, 1, name.length() - 1);
	}

	public static String toPascal(String name) {
		return Character.toUpperCase(name.charAt(0))
				+ StringUtils.substring(name, 1, name.length() - 1);
	}

	public static int getSuffixIndex(String name) {
		int start = name.length() - 1;
		for (; start != -1; start--) {
			char ch = name.charAt(start);
			if ((ch < '0') || (ch > '9')) {
				break;
			}
		}
		if (start == name.length() - 1) {
			return -1;
		}
		int index = 0;
		for (int i = start + 1; i < name.length(); i++) {
			index = index * 10 + (name.charAt(i) - '0');
		}
		return index;
	}
}
